#include "queue.h"

#include <unistd.h>

using namespace ai_service;

bool g_flag = true;

int main(int argc, char** argv)
{
    AsyncTaskQueue task_queue;
    task_queue.Loop(g_flag);

    AsyncTaskBase task;
    std::vector<TaskParamBase::ptr> ins;
    std::vector<TaskParamBase::ptr> outs;

    AsyncTaskParams params;
    params.input = ins;
    params.output = outs;

    std::thread t([&]() {
        while(1) {
            task.CommitTo(task_queue, params);
            task.Sync();
            usleep(50000);
        }
    });
    t.detach();

    std::thread t2([&]() {
        while(1) {
            task.CommitTo(task_queue, params);
            task.Sync();
            usleep(50000);
        }
    });
    t2.detach();

    while(1) {
        task.CommitTo(task_queue, params);
        task.Sync();
        usleep(50000);
    }
    return 0;
}